<template>
  <div class="building-container">
    <div class="person-container">
      <LeftMenu />
      <div class="building-content">
        <el-card>
          <ManagementTitle>
            <template #title>
              {{ plotName }}
              <el-button size="small" @click="goBack" style="margin-left: 16px;">返回小区管理</el-button>
            </template>
          </ManagementTitle>
          
          <!-- 小区基本信息 -->
          <div class="plot-info-card">
            <el-card shadow="never" class="info-card">
              <div class="plot-info">
                <!-- 左侧轮播图 -->
                <div class="plot-carousel-container" v-if="plotImages.length > 0">
                  <el-carousel
                    :interval="4000"
                    height="200px"
                    indicator-position="outside"
                    arrow="hover"
                  >
                    <el-carousel-item v-for="(image, index) in plotImages" :key="index">
                      <img
                        :src="image"
                        :alt="`小区图片${index + 1}`"
                        class="carousel-image"
                        @error="handleImageError"
                      />
                    </el-carousel-item>
                  </el-carousel>
                </div>

                <!-- 右侧信息详情 -->
                <div class="info-details" :class="{ 'with-carousel': plotImages.length > 0 }">
                  <!-- 主要信息区域 -->
                  <div class="main-info-section">
                    <div class="info-header">
                      <h3 class="plot-title">{{ plotInfo.name || plotName }}</h3>
                      <div class="location-tag">
                        <el-icon><LocationFilled /></el-icon>
                        <span>{{ plotInfo.countyName || '暂无' }}</span>
                      </div>
                    </div>

                    <!-- 核心信息网格 -->
                    <div class="core-info-grid">
                      <div class="info-card-item">
                        <div class="info-icon">
                          <el-icon><House /></el-icon>
                        </div>
                        <div class="info-content">
                          <div class="info-label">主力户型</div>
                          <div class="info-value">{{ plotInfo.type || '1-3居室' }}</div>
                        </div>
                      </div>

                      <div class="info-card-item">
                        <div class="info-icon">
                          <el-icon><Calendar /></el-icon>
                        </div>
                        <div class="info-content">
                          <div class="info-label">开业时间</div>
                          <div class="info-value">{{ formatDate(plotInfo.listTime || '') }}</div>
                        </div>
                      </div>

                      <div class="info-card-item">
                        <div class="info-icon">
                          <el-icon><Phone /></el-icon>
                        </div>
                        <div class="info-content">
                          <div class="info-label">客服电话</div>
                          <div class="info-value">{{ plotInfo.number || '400-888-0001' }}</div>
                        </div>
                      </div>
                    </div>
                  </div>

                  <!-- 详细信息区域 -->
                  <div class="detail-info-section">
                    <div class="detail-item-compact">
                      <span class="detail-label-compact">项目地址：</span>
                      <span class="detail-value-compact">{{ plotInfo.address || plotAddress || '朝阳区建国门外大街1号' }}</span>
                    </div>
                    <div class="detail-item-compact" v-if="plotInfo.brief">
                      <span class="detail-label-compact">项目简介：</span>
                      <span class="detail-value-compact">{{ plotInfo.brief }}</span>
                    </div>
                  </div>
                </div>
              </div>
            </el-card>
          </div>

          <!-- 楼栋列表标题 -->
          <div class="building-list-header">
            <h3 class="building-list-title">楼栋列表</h3>
            <el-button type="primary" @click="handlePlotPlanning">
              <el-icon><Setting /></el-icon>
              小区规划
            </el-button>
          </div>
          
          <!-- 楼栋网格 -->
          <div class="building-grid" v-loading="loading">
            <div 
              v-for="building in buildingList" 
              :key="building.id"
              class="building-card"
              @click="handleBuildingClick(building)"
            >
              <div class="building-header">
                <h3 class="building-name">{{ building.name }}栋</h3>
                <el-tag :type="building.delFlag === 0 ? 'success' : 'danger'" size="small">
                  {{ building.delFlag === 0 ? '正常' : '已删除' }}
                </el-tag>
              </div>
              
              <div class="building-stats">
                <div class="stat-item">
                  <span class="stat-label">单元数</span>
                  <span class="stat-value">{{ building.unitNum }}个</span>
                </div>
                <div class="stat-item">
                  <span class="stat-label">层数</span>
                  <span class="stat-value">{{ building.floorNum }}层</span>
                </div>
                <div class="stat-item">
                  <span class="stat-label">房屋总数</span>
                  <span class="stat-value">{{ building.totalHouses }}套</span>
                </div>
              </div>
              
              <div class="building-actions">
                <el-button size="small" type="primary" @click.stop="handleViewDetails(building)">
                  查看详情
                </el-button>
                <el-button size="small" type="success" @click.stop="handleManageTypes(building)">
                  户型管理
                </el-button>
              </div>
            </div>
          </div>
          
          <!-- 空状态 -->
          <div v-if="!loading && buildingList.length === 0" class="empty-state">
            <el-empty description="该小区暂无楼栋数据">
              <el-button type="primary" @click="handleAddBuilding">添加楼栋</el-button>
            </el-empty>
          </div>
        </el-card>
      </div>
    </div>

    <!-- 添加楼栋对话框 -->
    <el-dialog
      v-model="showAddDialog"
      title="添加楼栋"
      width="600px"
      :close-on-click-modal="false"
    >
      <el-form
        ref="buildingFormRef"
        :model="buildingForm"
        :rules="buildingFormRules"
        label-width="120px"
      >
        <el-form-item label="楼栋名称" prop="name">
          <el-input
            v-model="buildingForm.name"
            placeholder="请输入楼栋名称，如：1、A、甲等"
            maxlength="50"
            show-word-limit
          />
        </el-form-item>

        <el-form-item label="单元数" prop="unitNum">
          <el-input-number
            v-model="buildingForm.unitNum"
            :min="1"
            :max="20"
            @change="handleUnitNumChange"
          />
          <span class="form-tip">每栋楼的单元数量</span>
        </el-form-item>

        <el-form-item label="层数" prop="floorNum">
          <el-input-number
            v-model="buildingForm.floorNum"
            :min="1"
            :max="100"
          />
          <span class="form-tip">每个单元的层数</span>
        </el-form-item>

        <el-form-item label="各单元每层户数" prop="floorUserNumList">
          <div class="unit-config">
            <div
              v-for="(userNum, index) in buildingForm.floorUserNumList"
              :key="index"
              class="unit-item"
            >
              <span class="unit-label">{{ index + 1 }}单元：</span>
              <el-input-number
                v-model="buildingForm.floorUserNumList[index]"
                :min="1"
                :max="20"
                size="small"
              />
              <span class="unit-tip">户/层</span>
            </div>
          </div>
          <div class="form-tip">
            设置每个单元每层的户数，系统将自动计算总房屋数
          </div>
        </el-form-item>

        <el-form-item label="预计房屋总数">
          <span class="total-houses">{{ calculateTotalHouses() }}套</span>
        </el-form-item>
      </el-form>

      <template #footer>
        <span class="dialog-footer">
          <el-button @click="handleCancelAdd">取消</el-button>
          <el-button type="primary" @click="handleConfirmAdd" :loading="submitLoading">
            确定添加
          </el-button>
        </span>
      </template>
    </el-dialog>
  </div>
</template>

<script setup lang="ts">
import LeftMenu from "@/user/LeftMenu.vue";
import { ref, reactive, onMounted, computed } from "vue";
import ManagementTitle from "@/components/ManagementTitle.vue";
import { ElMessage } from 'element-plus';
import { Location, Setting, LocationFilled, House, Calendar, Phone } from '@element-plus/icons-vue';
import axios from 'axios';
import type { PlotInfo, Building } from "@/types/formRulesInterface";

// 响应式数据
const loading = ref(false);
const buildingList = ref<Building[]>([]);
const plotInfo = ref<PlotInfo>({});
const showAddDialog = ref(false);
const submitLoading = ref(false);
const plotImages = ref([]);

// 表单数据
const buildingForm = reactive({
  name: '',
  unitNum: 1,
  floorNum: 1,
  floorUserNumList: [1]
});

// 表单引用
const buildingFormRef = ref<any>(null);

// 表单验证规则
const buildingFormRules = {
  name: [
    { required: true, message: '请输入楼栋名称', trigger: 'blur' },
    { min: 1, max: 50, message: '楼栋名称长度在1到50个字符', trigger: 'blur' }
  ],
  unitNum: [
    { required: true, message: '请输入单元数', trigger: 'blur' },
    { type: 'number', min: 1, max: 20, message: '单元数必须在1到20之间', trigger: 'blur' }
  ],
  floorNum: [
    { required: true, message: '请输入层数', trigger: 'blur' },
    { type: 'number', min: 1, max: 100, message: '层数必须在1到100之间', trigger: 'blur' }
  ]
};

// URL参数
const urlParams = new URLSearchParams(window.location.search);
const plotId = ref(urlParams.get('plotId'));
const plotName = ref(decodeURIComponent(urlParams.get('plotName') || ''));
const plotAddress = ref(decodeURIComponent(urlParams.get('plotAddress') || ''));

// 工具函数
const formatDate = (dateStr: string) => {
  if (!dateStr) return '暂无';
  try {
    const date = new Date(dateStr);
    return date.toLocaleDateString('zh-CN');
  } catch {
    return '暂无';
  }
};



// API调用函数
const getPlotInfo = async () => {
  try {
    const response = await axios.get(`/rental/areaplot/${plotId.value}`);

    // 检查是否返回了HTML页面（代理失败）
    if (typeof response.data === 'string' && response.data.includes('<!DOCTYPE html>')) {
      // 尝试直接调用后端API
      const directResponse = await axios.get(`http://127.0.0.1:8000/rental/areaplot/${plotId.value}`);

      if (directResponse.data.code === 0) {
        plotInfo.value = directResponse.data.data || {};
        processPlotImages(plotInfo.value);
      }
    } else if (response.data.code === 0) {
      plotInfo.value = response.data.data || {};
      processPlotImages(plotInfo.value);
    }
  } catch (error) {
    console.error('获取小区信息失败:', error);
  }
};

// 处理小区图片
const processPlotImages = (plot: any) => {
  if (plot.ossUrls) {
    plotImages.value = plot.ossUrls.split(',').filter((url: string) => url.trim());
  } else {
    plotImages.value = [];
  }
};

// 图片加载错误处理
const handleImageError = (event: Event) => {
  const img = event.target as HTMLImageElement;
  img.src = '/src/assets/images/placeholder.png'; // 设置默认图片
};

const getBuildingList = async () => {
  loading.value = true;
  try {
    console.log('请求参数:', { plotId: plotId.value });
    console.log('请求URL:', `/rental/areabuilding/getBuildingByPlotId/${plotId.value}`);
    
    const response = await axios.get(`/rental/areabuilding/getBuildingByPlotId/${plotId.value}`, {
      timeout: 10000,
      headers: {
        'Content-Type': 'application/json',
        'Accept': 'application/json'
      }
    });
    
    console.log('响应数据:', response.data);
    
    // 检查是否返回了HTML页面（代理失败）
    if (typeof response.data === 'string' && response.data.includes('<!DOCTYPE html>')) {
      console.error('代理失败，尝试直接调用后端API');
      // 尝试直接调用后端API
      const directResponse = await axios.get(`http://127.0.0.1:8000/rental/areabuilding/getBuildingByPlotId/${plotId.value}`, {
        timeout: 10000,
        headers: {
          'Content-Type': 'application/json',
          'Accept': 'application/json'
        }
      });
      
      console.log('直接调用响应:', directResponse.data);
      
      if (directResponse.data.code === 0) {
        buildingList.value = directResponse.data.data.list || [];
        ElMessage.success(`成功获取 ${buildingList.value.length} 栋楼栋数据`);
      } else {
        ElMessage.error(directResponse.data.msg || '获取楼栋列表失败');
      }
    } else if (response.data.code === 0) {
      buildingList.value = response.data.data.list || [];
      ElMessage.success(`成功获取 ${buildingList.value.length} 栋楼栋数据`);
    } else {
      ElMessage.error(response.data.msg || '获取楼栋列表失败');
    }
  } catch (error) {
    console.error('获取楼栋列表失败:', error);
    ElMessage.error('获取楼栋列表失败，请检查网络连接');
  } finally {
    loading.value = false;
  }
};

const saveBuildingData = async (data: any) => {
  try {
    console.log('请求数据:', data);
    console.log('请求URL:', '/rental/areabuilding');

    const response = await axios.post('/rental/areabuilding', data, {
      timeout: 10000,
      headers: {
        'Content-Type': 'application/json',
        'Accept': 'application/json'
      }
    });

    console.log('响应数据:', response.data);

    // 检查是否返回了HTML页面（代理失败）
    if (typeof response.data === 'string' && response.data.includes('<!DOCTYPE html>')) {
      console.error('代理失败，尝试直接调用后端API');
      // 尝试直接调用后端API
      const directResponse = await axios.post('http://127.0.0.1:8000/rental/areabuilding', data, {
        timeout: 10000,
        headers: {
          'Content-Type': 'application/json',
          'Accept': 'application/json'
        }
      });

      console.log('直接调用响应:', directResponse.data);

      if (directResponse.data.code === 0) {
        ElMessage.success('楼栋添加成功');
        return true;
      } else {
        ElMessage.error(directResponse.data.msg || '添加楼栋失败');
        return false;
      }
    } else if (response.data.code === 0) {
      ElMessage.success('楼栋添加成功');
      return true;
    } else {
      ElMessage.error(response.data.msg || '添加楼栋失败');
      return false;
    }
  } catch (error) {
    console.error('添加楼栋失败:', error);
    ElMessage.error('添加楼栋失败，请检查网络连接');
    return false;
  }
};

// 事件处理函数
const goBack = () => {
  window.close();
};

const handleBuildingClick = (building: any) => {
  ElMessage.info(`点击了楼栋: ${building.name}栋`);
  // TODO: 跳转到楼栋详情页面
  console.log('楼栋信息:', building);
};

const handleViewDetails = (building: any) => {
  // 跳转到房源列表详情页面，传递楼栋信息
  window.open(`/landlord/house/list/details?buildingId=${building.id}&buildingName=${encodeURIComponent(building.name)}&plotName=${encodeURIComponent(plotName.value)}`, '_blank');
};

const handleManageTypes = (building: any) => {
  // 跳转到户型管理页面，传递楼栋ID
  window.open(`/landlord/type/management?buildingId=${building.id}&buildingName=${encodeURIComponent(building.name)}栋&plotName=${encodeURIComponent(plotName.value)}`, '_blank');
};

const handleAddBuilding = () => {
  showAddDialog.value = true;
  resetBuildingForm();
};

const handlePlotPlanning = () => {
  // 跳转到小区规划页面
  window.open(`/landlord/plot/planning?plotId=${plotId.value}&plotName=${encodeURIComponent(plotName.value)}&plotAddress=${encodeURIComponent(plotAddress.value || '')}`, '_blank');
};

// 表单处理方法
const resetBuildingForm = () => {
  buildingForm.name = '';
  buildingForm.unitNum = 1;
  buildingForm.floorNum = 1;
  buildingForm.floorUserNumList = [1];
  if (buildingFormRef.value) {
    buildingFormRef.value.clearValidate();
  }
};

const handleUnitNumChange = (value: number) => {
  const currentLength = buildingForm.floorUserNumList.length;
  if (value > currentLength) {
    // 增加单元，默认每层1户
    for (let i = currentLength; i < value; i++) {
      buildingForm.floorUserNumList.push(1);
    }
  } else if (value < currentLength) {
    // 减少单元
    buildingForm.floorUserNumList = buildingForm.floorUserNumList.slice(0, value);
  }
};

const calculateTotalHouses = () => {
  return buildingForm.floorUserNumList.reduce((sum, userNum) => sum + userNum * buildingForm.floorNum, 0);
};

const handleCancelAdd = () => {
  showAddDialog.value = false;
  resetBuildingForm();
};

const handleConfirmAdd = async () => {
  if (!buildingFormRef.value) return;

  try {
    await buildingFormRef.value.validate();

    submitLoading.value = true;

    const buildingData = {
      name: buildingForm.name,
      plotId: parseInt(plotId.value || '0'),
      unitNum: buildingForm.unitNum,
      floorNum: buildingForm.floorNum,
      floorUserNumList: [...buildingForm.floorUserNumList]
    };

    console.log('提交楼栋数据:', buildingData);

    const success = await saveBuildingData(buildingData);
    if (success) {
      showAddDialog.value = false;
      resetBuildingForm();
      getBuildingList(); // 重新获取楼栋列表
    }
  } catch (error) {
    console.error('表单验证失败:', error);
  } finally {
    submitLoading.value = false;
  }
};

// 初始化
onMounted(() => {
  if (!plotId.value) {
    ElMessage.error('缺少小区ID参数');
    return;
  }
  getPlotInfo();
  getBuildingList();
});
</script>

<style scoped>
.building-container {
  display: flex;
  flex-direction: column;
}

.person-container {
  max-width: 1290px;
  width: 100%;
  margin: 20px auto;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  box-sizing: border-box;
  padding: 0 16px;
}

.building-content {
  margin-left: 10px;
  flex: 1 1 0;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}

.plot-info-card {
  margin-bottom: 20px;
}

.info-card {
  background: white;
  border: 1px solid #e4e7ed;
}

:deep(.info-card .el-card__body) {
  padding: 20px;
}

.plot-info {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  min-height: 200px;
}

.plot-carousel-container {
  flex: 0 0 300px;
  width: 300px;
  height: 200px;
  overflow: hidden;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.carousel-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 8px;
}

.info-details {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  min-width: 0;
  padding: 8px 0;
  height: fit-content;
}

.info-details.with-carousel {
  flex: 1;
}

/* 没有轮播图时，信息详情占满整个宽度 */
.plot-info:not(:has(.plot-carousel-container)) .info-details {
  width: 100%;
}

/* 主要信息区域 */
.main-info-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.plot-title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  color: #303133;
  line-height: 1.2;
}

.location-tag {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  background: linear-gradient(135deg, #409eff, #67c23a);
  color: white;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
}

.location-tag .el-icon {
  font-size: 14px;
}

/* 核心信息网格 */
.core-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.info-card-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #f8f9fa;
  border-radius: 8px;
  border-left: 3px solid #409eff;
  transition: all 0.3s ease;
}

.info-card-item:hover {
  background: #e6f7ff;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(64, 158, 255, 0.15);
}

.info-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: #409eff;
  color: white;
  border-radius: 6px;
  flex-shrink: 0;
}

.info-icon .el-icon {
  font-size: 16px;
}

.info-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.info-label {
  font-size: 12px;
  color: #909399;
  font-weight: 500;
  line-height: 1;
}

.info-value {
  font-size: 14px;
  color: #303133;
  font-weight: 600;
  line-height: 1.2;
  word-break: break-all;
}

/* 详细信息区域 */
.detail-info-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid #e4e7ed;
  margin-top: 4px;
}

.detail-item-compact {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 0;
  margin-bottom: 0;
}

.detail-label-compact {
  font-weight: 600;
  color: #606266;
  white-space: nowrap;
  min-width: 80px;
  font-size: 14px;
}

.detail-value-compact {
  color: #303133;
  font-size: 14px;
  line-height: 1.4;
  word-break: break-all;
  flex: 1;
}

.building-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 24px 0 16px 0;
  padding: 16px 0;
  border-top: 1px solid #e4e7ed;
}

.building-list-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #303133;
}

.building-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.building-card {
  background: white;
  border: 2px solid #e4e7ed;
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.building-card:hover {
  border-color: #409eff;
  box-shadow: 0 4px 16px rgba(64, 158, 255, 0.2);
  transform: translateY(-2px);
}

.building-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.building-name {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: #303133;
}

.building-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #f8f9fa;
  border-radius: 6px;
}

.stat-label {
  font-size: 14px;
  color: #606266;
}

.stat-value {
  font-weight: 600;
  color: #303133;
}

.stat-value.selected {
  color: #409eff;
}



.building-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.building-actions .el-button {
  flex: 1;
}

.empty-state {
  margin-top: 40px;
  text-align: center;
}

:deep(.el-card) {
  min-height: auto;
}

:deep(.el-card__body) {
  padding: 20px;
}

:deep(.el-progress-bar__outer) {
  border-radius: 3px;
}

:deep(.el-progress-bar__inner) {
  border-radius: 3px;
}

/* 响应式设计 - 中等屏幕 */
@media (max-width: 1200px) {
  .plot-info {
    flex-direction: column;
    gap: 20px;
  }

  .plot-carousel-container {
    flex: none;
    width: 100%;
    max-width: 400px;
    height: 180px;
    margin: 0 auto;
  }

  .carousel-image {
    height: 180px;
  }

  .info-details.with-carousel {
    flex: none;
  }

  .core-info-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
  }

  .info-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .plot-title {
    font-size: 20px;
  }
}

@media (max-width: 900px) {
  .person-container {
    flex-direction: column;
    align-items: stretch;
    padding: 0 4px;
  }

  .building-content {
    margin-left: 0;
    width: 100%;
    max-width: 100%;
  }

  .building-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .building-list-header {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .building-stats {
    grid-template-columns: 1fr;
  }

  .building-actions {
    flex-direction: column;
  }

  .plot-carousel-container {
    width: 100%;
    max-width: none;
    height: 160px;
  }

  .carousel-image {
    height: 160px;
  }

  .core-info-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .info-card-item {
    padding: 10px 12px;
  }

  .info-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .plot-title {
    font-size: 18px;
  }

  .location-tag {
    align-self: flex-start;
  }

  .detail-item-compact {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 8px 0;
  }

  .detail-label-compact {
    min-width: auto;
    font-size: 13px;
  }

  .detail-value-compact {
    font-size: 13px;
  }
}

/* 添加楼栋对话框样式 */
.form-tip {
  margin-left: 8px;
  font-size: 12px;
  color: #909399;
}

.unit-config {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.unit-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.unit-label {
  min-width: 60px;
  font-size: 14px;
  color: #606266;
}

.unit-tip {
  font-size: 12px;
  color: #909399;
}

.total-houses {
  font-size: 16px;
  font-weight: 600;
  color: #409eff;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

:deep(.el-dialog__body) {
  padding: 20px;
}

:deep(.el-form-item__label) {
  font-weight: 500;
}

:deep(.el-input-number) {
  width: 120px;
}

@media (max-width: 600px) {
  .unit-config {
    gap: 8px;
  }

  .unit-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .unit-label {
    min-width: auto;
  }
}

/* 小区图片轮播样式 */
.plot-carousel-container {
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.carousel-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

:deep(.el-carousel__item) {
  border-radius: 0;
  overflow: hidden;
}

:deep(.el-carousel__indicator) {
  background-color: rgba(0, 0, 0, 0.3);
}

:deep(.el-carousel__indicator.is-active) {
  background-color: #409eff;
}

:deep(.el-carousel__button) {
  background-color: rgba(255, 255, 255, 0.8);
}

:deep(.el-carousel__arrow) {
  background-color: rgba(0, 0, 0, 0.5);
}

:deep(.el-carousel__arrow:hover) {
  background-color: rgba(0, 0, 0, 0.7);
}
</style>
